<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                template="./../../resources/estoque.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="estilo.css" />
        <h:outputScript library="js" name="javaScript.js" />
        <p:separator />
        <div class="pagina">
            Relatorio de Saídas de Produtos
        </div>        
        <p:separator />
        <p:growl />
        <h:form id="relEntrada">
            <p:fieldset legend="Filtro"  style="width: 90%;">
                <h:panelGrid columns="5">
                    <h:outputLabel for="dtInicio" value="Data Inicio.:" />
                    <p:calendar id="dtInicio" value="#{relatorioSaida.dataInicio}" />
                    <h:outputLabel for="dtFinal" value="Data Final.:" />
                    <p:calendar id="dtFinal" value="#{relatorioSaida.dataFinal}" />
                    <p:commandButton value="Listar Saidas" action="#{relatorioSaida.saidaProdutoPeriodo}" ajax="false" />
                </h:panelGrid>               
            </p:fieldset>
        </h:form>
        <p:separator />
        <h:form id="tabSaida" rendered="#{relatorioSaida.saidas.size() > 0}">
            <p:dataTable value="#{relatorioSaida.saidas}" var="p">
                <p:column headerText="Data">
                    <h:outputText value="#{p.data}">
                        <f:convertDateTime pattern="dd/MM/yyyy" />
                    </h:outputText>
                </p:column>
                <p:column headerText="Produto">
                    <h:outputText value="#{p.produto.descricao}" />
                </p:column>
                <p:column headerText="Qtde">
                    <h:outputText value="#{p.quantidade}" />
                </p:column>
            </p:dataTable> 

            <p:commandButton value="Imprimir Lista por Data" ajax="false">
                <p:fileDownload value="#{relatorioSaida.arquivoRetorno}" />
            </p:commandButton>
            <p:commandButton value="Imprimir Lista por Produto" ajax="false">
                <p:fileDownload value="#{relatorioSaida.arquivoRetornoProduto}" />
            </p:commandButton>
        </h:form>
    </ui:define>

</ui:composition>
